Intersoft WebTextEditor Documentation
How-to: Add Custom ToolBar using InitializeToolBar server-side event
See Also Send Feedback
Intersoft WebTextEditor > WebTextEditor > ToolBar > Customize toolbar programmatically from server-side > How-to: Add Custom ToolBar using InitializeToolBar server-side event

Glossary Item Box

WebTextEditor provides a property to add custom toolbar during InitializeToolBar server side event.

In this topic, you will learn how to add custom toolbar.

To custom toolbar during Server Side event

  1. Implement InitializeToolBar server side event in the WebTextEditor. Here is the snippet to add the custom toolbar with some commands to the WebTextEditor:
    C# Copy Code
    protected void WebTextEditor1_InitializeToolBar(object sender, ISNet.WebUI.WebTextEditor.WebTextEditorToolBarArgs e)
    {   
       WebTextEditorToolBar tbCustom = new WebTextEditorToolBar();  
       tbCustom.Name = "tbCustom";   
    
       WebTextEditorToolCommand cmdCustom1 = new WebTextEditorToolCommand();  
       cmdCustom1.Name = "cmdCustom1";  
       cmdCustom1.Text = "Custom Button 1";   
    
       WebTextEditorToolCommand cmdCustom2 = new WebTextEditorToolCommand();  
       cmdCustom2.Name = "cmdCustom2";  
       cmdCustom2.Text = "Custom Button 2";   
    
       tbCustom.ToolCommands.Add(cmdCustom1);  
       tbCustom.ToolCommands.Add(cmdCustom2);   
       
       WebTextEditor1.ToolBar.Add(tbCustom);
    }
    

  2. Implement onToolBarClick client side event to display a message when the newly created command in the custom toolbar is clicked. Here is the snippet:
    Javascript Copy Code
    function WebTextEditor1_OnToolBarClick(controlId, command, commandSection)
    {    
       var rte = ISGetObject(controlId);     
    
       switch (command.Name)    
       {        
          case "cmdCustom1":            
                alert("Custom button 1 clicked");            
                break;        
    
          case "cmdCustom2":            
                alert("Custom button 2 clicked");            
                break;    
       }
    }
    

See Also

©2013. All Rights Reserved.